<!--
 * @Author: your name
 * @Date: 2021-04-16 10:54:02
 * @LastEditTime: 2021-04-23 15:27:23
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \dolphin-data-center-front-end\src\pages\authorityManagement\personalDetails.vue
-->
<template>
  <page-layout :avatar="avatar" title=" ">
    <div slot="headerContent">
      <div class="title">{{name}}</div>
      <div>{{department}}-{{position}}</div>
    </div>
    <detail :isMember="false" :pageData="pageData"></detail>
  </page-layout>
</template>

<script>
import Detail from "@/pages/owns/Detail";
import PageLayout from "@/layouts/PageLayout";
import {
  employeeInfo
} from '@/services/staff';
export default {
  name: "personalDetails",
  components: { Detail, PageLayout },
  data () {
    return {
      pageData: [],
      name: "",
      avatar: "https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png",
      department: "",
      position: ""
    };
  },
  watch: {
    $route: {
      handler (to) {
        const id = to.query.id;
        employeeInfo({ id: id }).then(res => {
          if (res.data.code == 200) {
            const data = res.data.data;
            this.avatar = data.avatar;
            this.name = data.realName;
            this.department = data.userDeptList[0].name;
            this.position = data.postName;
            const userAuthorityList = data.userAuthorityList;
            const roleAuthorityList = data.roleAuthorityList;
            userAuthorityList.map((val, index) => {
              roleAuthorityList.filter(val1 => val1.type == val.type && userAuthorityList.splice(index, 1))
            })
            userAuthorityList.forEach(val => {
              val.disabled = true
            });
            this.pageData = roleAuthorityList.concat(userAuthorityList)
          }
        })
      },
      immediate: true
    }
  }
};
</script>

<style scoped lang="less">
</style>
